package com.Maykk.StuManagerT;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @ClassName: StuPage
 * @Description: TODO 视图层 —— 显示前端输出
 * @Author: MaykkStar@163.com
 */
public class StuPage {
    public static int Welcome() {
        System.out.println("+++++++++++++");
        System.out.println("+ 1.查询学员 +");
        System.out.println("+ 2.添加学员 +");
        System.out.println("+ 3.修改学员 +");
        System.out.println("+ 4.删除学员 +");
        System.out.println("+ 0.退出系统 +");
        System.out.println("+++++++++++++");
        int choose;
        do {
            System.out.print("请输入：");
            choose = new Scanner(System.in).nextInt();
        } while (0 > choose || 4 < choose);
        return choose;
    }

    public static int serchPage() {
        System.out.println("* *********** *");
        System.out.println("* 查询功能选择页面");
        System.out.println("* 1 - 查询全部");
        System.out.println("* 2 - 按学号查询");
        System.out.println("* 3 - 按姓名查询");
        System.out.println("* 4 - 按性别查询");
        System.out.println("* 5 - 按年龄查询");
        System.out.println("* 6 - 按成绩查询");
        System.out.println("* 0 - 返回主菜单");
        System.out.println("* *********** *");
        int choose;
        do {
            System.out.print("请输入：");
            choose = new Scanner(System.in).nextInt();
        } while (0 > choose || 6 < choose);
        return choose;
    }

    /**
     * 输出学员信息
     *
     * @param stuList 学生集合
     */
    public static void showList(ArrayList<Student> stuList) {
        System.out.print("┌────┬────────────┬──────┬──────┬──────┐\n");
        System.out.printf("│%-4s│%-12s│%-6s│%-6s│%-6s│\n", "ID", "NAME", "SEX", "AGE", "SCORE");
        for (Student stu : stuList) {
            System.out.print("├────┼────────────┼──────┼──────┼──────┤\n");
            System.out.printf("│%-4d│%-12s│%-6s│%-6d│%-6.1f│\n",
                    stu.getId(),
                    stu.getName(),
                    stu.getSex(),
                    stu.getAge(),
                    stu.getScore());
        }
        System.out.print("└────┴────────────┴──────┴──────┴──────┘\n");
    }

    public static int inputID() {
        System.out.print("请输入学员ID：");
        return new Scanner(System.in).nextInt();
    }

    public static String inputName() {

        System.out.print("请输入学员姓名：");
        return new Scanner(System.in).nextLine();
    }

    public static String inputSex() {
        System.out.print("请输入性别：");
        return new Scanner(System.in).nextLine();
    }

    public static int inputAge() {
        System.out.print("请输入学员年龄：");
        return new Scanner(System.in).nextInt();
    }

    public static float inputScore() {
        System.out.println("请输入学员成绩：");
        return new Scanner(System.in).nextFloat();
    }

    public static Student inputStuInfo() {
        System.out.println("请输入学员姓名");
        String stuName = new Scanner(System.in).nextLine();
        System.out.println("请输入学员性别");
        String stuSex = new Scanner(System.in).next();
        System.out.println("请输入学员年龄");
        int stuAge = new Scanner(System.in).nextInt();
        System.out.println("请输入学员成绩");
        float stuScore = new Scanner(System.in).nextFloat();
        return new Student(stuName, stuSex, stuAge, stuScore);
    }

    public static void showOutcome(boolean b) {
        if (b) System.out.println("成功");
        else System.out.println("失败");
        ;
    }

    /**
     * 用户执行确认操作
     * @return “
     */
    public static boolean AreYouOK() {
        System.out.println("是否确认操作：\n Y. 确定 \n N. 返回");
        switch (new Scanner(System.in).next()) {
            case "Y":
            case "y":
                return true;
            case "N":
            case "n":
                return false;
            default:
                System.out.println("输入错误，即将返回菜单");
        }
        return false;
    }

    public static Student editStuInfo(ArrayList<Student> editStuInfo) {
        System.out.println("请输入学员姓名");
        String stuName = new Scanner(System.in).nextLine();
        System.out.println("请输入学员性别");
        String stuSex = new Scanner(System.in).next();
        System.out.println("请输入学员年龄");
        int stuAge = new Scanner(System.in).nextInt();
        System.out.println("请输入学员成绩");
        float stuScore = new Scanner(System.in).nextFloat();
        return new Student(editStuInfo.get(0).getId(),stuName, stuSex, stuAge, stuScore);
    }

    public static void showDelStu(int delStuID) {
    }

    public static void showErr(String s) {
        System.out.println(s);
    }
}
